package com.eorchis.module.user.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.eorchis.core.basedao.dao.impl.HibernateAbstractBaseDao;
import com.eorchis.module.classuser.domain.ClassUser;
import com.eorchis.module.user.dao.IUserUpdateDao;
import com.eorchis.module.user.domain.ClassUserChangeLog;
import com.eorchis.module.user.ui.commond.UserInfoValidCommond;

@SuppressWarnings({ "unchecked", "deprecation" })
@Repository(value = "com.eorchis.module.user.dao.impl.UserUpdateDaoimpl")
public class UserUpdateDaoimpl extends HibernateAbstractBaseDao implements IUserUpdateDao {

	@Override
	public List<UserInfoValidCommond> queryChengeBeforeUserInof(UserInfoValidCommond userValidCommond) throws Exception {
		StringBuffer sql = new StringBuffer();
		Map<String,Object> params = new HashMap<String, Object>();
		sql.append(" select t.User_Name as \"userName\",t.SEX_CODE as \"sexCode\",");
		sql.append(" t.FOLK_CODE as \"folkCode\",date_format(t.birthday,'%Y-%m-%d') as \"birthday\",t.duty_Level_Code as \"rank\",");
		sql.append(" t.DUTY_REMARK as \"dutyRemark\",t.REMARK as \"remark\"");
		sql.append(" from TRAINING_CLASS_USER t where t.USER_ID =:userId");
		params.put("userId", userValidCommond.getUserId());
		return (List<UserInfoValidCommond>) executeFind(QueryStringType.SQL, sql.toString(),params,UserInfoValidCommond.class );
	}

	@Override
	public List<ClassUserChangeLog> queryChangeLogByUserId(UserInfoValidCommond userValidCommond) throws Exception {
		StringBuffer sql = new StringBuffer();
		Map<String,Object> params = new HashMap<String, Object>();
		sql.append(" select t.CHANGELOG_ID as \"changelogID\"");
		sql.append(" from TRAINING_CLASS_USER_CHANGE_LOG t");
		sql.append(" where t.USER_ID =:userId");
		params.put("userId", userValidCommond.getUserId());
		return (List<ClassUserChangeLog>) executeFind(QueryStringType.SQL, sql.toString(),params,ClassUserChangeLog.class );
	}
}
